package com.happy_lab_management.demo.student.lab.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.happy_lab_management.demo.student.lab.mapper.LabMapper;
import com.happy_lab_management.demo.student.lab.service.LabService;
import com.happy_lab_management.entity.ExperimentApplication;
import com.happy_lab_management.entity.Lab;
import com.happy_lab_management.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("studentLabService")
public class LabServiceImpl extends ServiceImpl<LabMapper, Lab> implements LabService {
    @Autowired
    private LabMapper labMapper;
    public List<Lab> selectByTechnicianId(Integer id) {
        return labMapper.selectByTechnicianId(id);
    }

    public Result<List<String>> listAlLType() {
        return labMapper.listAlLType();
    }

    public List<Lab> selectFreeLabs(ExperimentApplication experimentApplication) {
        QueryWrapper<Lab> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("lab_type",experimentApplication.getLabType());
        queryWrapper.ge("equipment_count",experimentApplication.getStudentCount());
        return  labMapper.selectList(queryWrapper);
    }

    public Lab selectByLabNumber(Integer labNumber) {
        QueryWrapper<Lab> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("lab_number",labNumber);
        return labMapper.selectOne(queryWrapper);
    }


}
